#pragma once

#include "QBond.h"
#include "../BondInfo.h"
#include "BondFilterFunc.h"
#include "../bondlib.h"
#include <core/strings/BaseString.h>
#include <qbprotocol/include/SSFilters.h>
#include <vector>
#include <map>
#include <string>

#pragma warning( disable: 4251 )

#define USE_BOND_DEBUG

class CAdditionBondInfo;
class CBondInfoImpl
{
public:
	class RawFlag{
		int				m_nIsQuotTopflag;					//是否置顶,			编码: 1:置顶
		bool			m_bIsValid;							//true表示有效债券，否则为无效债券
		char			m_sMortgage;						//可质押				编码："Y"
		char			m_sCrossmarket;						//跨市场				编码："Y","N"
		char			m_sIsMunicipal;						//城投					编码："Y"
	public:
		RawFlag() :m_nIsQuotTopflag(0), m_bIsValid(false), m_sMortgage('\0'), m_sCrossmarket('\0'), m_sIsMunicipal('\0'){}
		void SetStickFlag(int tp){ m_nIsQuotTopflag = tp; }
		void SetValidFlag(bool valid){ m_bIsValid = valid; }
		void SetMortgageFlag(char sMortgage){ m_sMortgage = sMortgage; }
		void SetCrossmarketFlag(char sCrossmarket){ m_sCrossmarket = sCrossmarket; }
		void SetMunicipalFlag(char sMunicipal){ m_sIsMunicipal = sMunicipal; }
		bool GetStickFlag()const{return m_nIsQuotTopflag == 0 ? false : true; }
		bool GetValidFlag()const{return m_bIsValid; }
		char GetMortgageFlag()const{ return m_sMortgage; };
		char GetCrossmarketFlag()const{ return m_sCrossmarket; };
		char GetMunicipalFlag()const{ return m_sIsMunicipal; };
	};
	typedef CBondInfoBitFlag FieldFlag;
	//friend class CBondInfoDebug;
public:
	const FieldFlag& GetFlag()const{ return m_flag; }
	void SetFlag(const FieldFlag& flag){ m_flag = flag; }
	void* operator new(size_t  bytes);
	void operator delete(void*);
private://禁止在堆上创建CBondInfoImpl数组
	void* operator new[](size_t bytes) throw() {return nullptr; }
	void operator delete[](void* ptr){}
public:
	CBondInfoImpl();
	~CBondInfoImpl();
	CBondInfoImpl& operator=(const CBondInfoImpl& bi);
	bool operator==(const CBondInfoImpl& bi)const;
	bool operator!=(const CBondInfoImpl& bi)const;
public:// 通用的用于调试的接口

	// 获取所有字段的信息
	int GetAllFields(std::vector<FieldInfo>& fields)const;

	// 获取
	int GetFieldInfo(int offset, char* name, FieldAccessMode mode)const;
	void WriteField(int offset, const char* str, int len);
	int ReadField(int offset, void* buf, int capcity, int& type)const;
	int GetStorageBytes(int offset)const;
	int GetFieldCategory(int offset)const;
	int GetFieldType(int offset)const;
	const char* SyncField(int offset, const char* input, int len, bool write);
public:
	void	Clear();//初始化数据	
	bool	IsCodeEqualTo(const char * szBondID, const char * szListedMarket)const;
	bool	IsKeyEqualTo(const char * szBondKey, const char * szListedMarket)const;

	bool	IsEqualTo(const char * szBondID, const char * szListedMarket)const;//deprecated 
	//设置成员参数
public:
	//2016/04/08 by devin.zhang:
	enum FilterCallbackType
	{
		FCT_NULL = 0,
		FCT_TYPE,	//产品类型
	};

	//2016/12/08 by devin.zhang: 
	enum IssueTypes
	{
		IssueNONE = 0,	//未定义
		IssueRAT,		//利率
		IssuePRC,		//价格
		IssueSPD,		//利差
		IssueAMT,		//数量招标
	};

	//typedef bool(__stdcall *_BONDFILTER)(UINT nBondType, const CBondInfoImpl& bi);

	class MAP_BONDFILTER
	{
	public:
		typedef std::map<uint32_t, _BONDFILTER>::iterator ITR;
		std::map<uint32_t, _BONDFILTER> mapFilter;
	};

public:
	void	SetBondKey(const char * szKey);							//m_sBondKey
	void	SetBondCode(const char * szCode);							//m_sBondID
	void	SetListedMarket(const char * szListedMarket);				//m_sListedMarket
	void	SetCombBondKey(const char * szKey);						//m_sCombBondKey
	void	SetCombBondCode(const char * szCode);						//m_sCombBondID

	//m_sJianpin
	//m_sQuanpin 由SetBondShortName函数设置

	void	SetMarketType(const char *szMarketType);					//m_sMarketType
	void	SetBondSubType(const char *szBondSubType);					//m_sBondSubType
	void	SetIssuerRating(const char *szIssuerRating);				//m_sIssuerRating
	void	SetIssuerRatingInstitutionCode(const char *sIssuerRatingInstitutionCode);//m_sIssuerRatingInstitutionCode
	void	SetBondRating(const char *szCurrent);						//m_sBondRating
	void	SetInstitutionRating(const char * sInstitutionRating);		//m_sInstitutionRating;
	void	SetListDate(const char *szListDate);						//m_sListDate

	void SetCBRRating(const char* szCBRRating);
	void SetChinaDCState(const char* szChinaDCState);

	void	SetCDCRating(const char * szCDCRating);
	void	SetCSIRating(const char * szCSIRating);

	void	SetInterestStartDate(const char *szStartdate);			//m_sInterestStartDate
	void	SetMaturityDate(const char *szDate);						//m_sMaturityDate
	void	SetPaymentDate(const char * szPaymentDate);				//m_sPaymentDate
	void	SetPayDate(int nDate);						//m_nPayDate
	void	SetOptionDate(const char *szOptionDate);					//m_sOptionDate
	void	SetRateType(const char *szRateType);						//m_sRateType
	void	SetCouponType(const char *szCouponType);					//m_sCouponType
	void	SetCouponFrequency(const char * szCouponFrequency);		//m_sCouponFrequency
	void	SetCompoundFrequency(const char * szCompoundFrequency);	//m_sCompoundFrequency
	void	SetInterestBasis(const char * szInterestBasis);			//m_sInterestBasis

	void	SetOptionType(const char * szOptionType);				//m_sOptionType
	void	SetMaturityTerm(const char * szMaturityTerm);			//m_sMaturityTerm
	void	SetTermToMaturity(const char * szTermToMaturity);		//m_sTermToMaturity
	void	SetFRNIndexID(const char *szIndexID);					//m_sFRNIndexID
	void	SetFixingMADays(const char* szFixingMADays);			//m_sFixingMADays
	void	SetCouponRateCurrent(const char* szCouponRateCurrent);	//m_sCouponRateCurrent
	void	SetWarranter(const char* szWarranter);					//m_sWarranter
	void	SetBondTag(const char* szBondTag);						//m_sBondTag

	void	SetPlannedIssueAmount(double fPlannedIssueAmount);		//m_fPlannedIssueAmount
	void	SetActualIssueAmount(double fActualIssueAmount);			//m_fActualIssueAmount
	void	SetOutstandingAmount(double fOutstandingAmount);			//m_fOutstandingAmount
	void	SetIssuerCode(const char * szIssuerCode);					//m_sIssuerCode
	void	SetInstitutionType(const char *szInsType);				//m_sInstitutionType

	void	SetYieldCurveType(const char *szCurveType);				//m_sYieldCurveType
	//void	SetCSDate(UINT nCSDate);								//m_nCSDate

	//void	SetCSYield(const char *szYield);							//m_sCSYield	
	//void	SetCSCleanPrice(const char *szPrice);						//m_sCSCleanPrice
	//void	SetCSModifyDuration(const char *szDuration);				//m_sCSModifyDuration


	void	SetAutcionType(const char * szAutcionType);					//m_sAutcionType
	void	SetAuctionDateStart(const char * szAuctionDateStart);		//m_sAuctionDateStart
	void	SetAuctionDateEnd(const char * szAuctionDateEnd);			//m_sAuctionDateEnd
	void	SetAuctionDateTime(const char * szAuctionDateTime);		//m_sAuctionDateTime
	void	SetAnnounceDate(const char * szAnnounceDate);				//m_sAnnounceDate
	void	SetIssueType(const char * szIssueType);						//m_sIssueType
	void	SetIssueStartDate(const char * szIssueStartDate);			//m_sIssueStartDate
	void	SetIssueEndDate(const char * szIssueEndDate);				//m_sIssueEndDate
	void	SetIssueEndTime(const char * szIssueEndTime);				//m_sIssueEndTime
	void	SetIssuePeriod(const char * szIssuePeriod);				//m_sIssuePeriod
	void	SetAuctionTimeStart(int nAuctionTimeStart);					//m_nAuctionTimeStart
	void	SetAuctionTimeEnd(int nAuctionTimeEnd);						//m_nAuctionTimeEnd

	void	SetQuotTopflag(int tp);									//m_nIsQuotTopflag
	void	SetWarrant(const char* szWarrant);						//m_sWarrant
	void	SetMortgage(char sMortgage);								//m_sMortgage
	void	SetCrossmarket(char sCrossmarket);						//m_sCrossmarket
	void	SetMunicipal(char sMunicipal);							//m_sIsMunicipal

	//m_bidinfo
	//m_askinfo
	//	bool	SetPriceInfo( REPORT * pReport, int bidask );				//m_bidinfo,m_askinfo

	void	SetMainUnderwriters(const char * sUnderwriters);			//m_sMainUnderwriters
	void	SetJointUnderwriters(const char * sUnderwriters);			//m_sJointUnderwriters
	void	SetUnderwrites(const char * sUnderwrites);					//m_sUnderwrites
	void	SetBidLimitBottom(const char * sBid);						//m_sBidLimitBottom
	void	SetBidLimitTop(const char * sBid);							//m_sBidLimitTop

	void	SetAuctionFlr(const char * sAuction);						//m_sAuction_Flr
	void	SetAuctionCap(const char * sAuction);						//m_sAuction_Cap
	void	SetAuctionStep(const char * sStep);						//m_sAuction_Step	
	void	SetAuctionUnit(const char * sUnit);						//m_sAuction_Unit

	void	SetRemainDate(const char * sRemainDate);					//m_sRemainDate
	void	SetBondName(const char * szName);							//m_sFullName
	void	SetBondShortName(const char *szShortName);				//m_sShortName,m_sJianpin,m_sQuanpin
	void	SetBondNameEn(const char* szNameEn);						//m_sFullNameEn
	void	SetBondShortNameEn(const char* szShortNameEn);			//m_sShortNameEn

	void    SetOutlook(const char * sOutlook);							//Outlook
	void    SetEntCor(const char *sEntCor);								//EntCor

	void	SetBondFileNum(int nBondFileNum);							//m_nBondFileNum
	void	SetAdditionInfoIndex(int nIndex);							//m_nAdditionInfoIndex
	void	SetOptionInfoIndex(int nIndex);								//m_nOptionInfoIndex


	void    SetIssueRate(const char * sIssueRate);						//m_IssueRate
	void	SetPlannedExerciseDate(const char * sDate);					//m_PlannedExerciseDate 
	void    SetNextCoupon_Date(const char *sDate);						//m_NextCoupon_Date
	void    SetConversionRate(const char* sRate);						//m_ConversionRate
	void	SetAssetStatus(const char* sAssetStatus);					//m_sAssetStatus
	void SetPrincipalPayType(const char* szPrincipalPayType);	//m_sPrincipayPayType

	void	SetCdcAuth(int nCdcAuth);									//m_nCdcAuth;
	void	SetExpireInHoliday(bool bHoliday);							//m_bExpireInHoliday

	void	SetCurrency(const char* sCurrency);							//m_sCurrency
	void	SetSceniority(const char* szSceniority);
	void	SetCategoryFlag(const char* szCategoryFlag);
	//得到成员函数,内联函数为了更好的效率
public:
	const char * GetBondKey()		const;		//m_sBondKey
	const char * GetBondCode()		const;		//m_sBondID
	const char * GetListedMarket()	const;	//m_sListedMarket 获取市场代码
	const char * GetCombBondKey()	const;	//m_sCombBondKey 获取bondkey+market  eg: **********.CIB,  ****************.SSE,  **************.SZE
	const char * GetCombBondCode()	const;	//m_sCombBondID  获取bondcode+market  eg:  600000,   600000.SH,    600000.SZ

	std::string GetBondJianpin()	const;//m_sJianpin
	std::string GetBondQuanpin()	const;//m_sQuanpin
	const char * GetMarketType()	const;	//m_sMarketType
	const char * GetBondSubType()	const;	//m_sBondSubType
	const char * GetIssuerRating()	const;	//m_sIssuerRating
	const char * GetIssuerRatingInstitutionCode() const; //m_sIssuerRatingInstitutionCode
	const char * GetInstitutionRating()const;//m_sInstitutionRating

	const char * GetBondRating()	const;	//m_sBondRating
	const char * GetListDate()		const;		//m_sListDate
	const char * GetInterestStartDate()const;//m_sInterestStartDate
	const char * GetMaturityDate()	const;	//m_sMaturityDate
	const char * GetPaymentDate()	const;	//m_sPaymentDate
	int GetPayDate()		const;	//m_nPayDate

	const char * GetOptionDate()	const;	//m_sOptionDate
	const char * GetRateType()		const;		//m_sRateType
	const char * GetCouponType()	const;	//m_sCouponType
	const char * GetCouponFrequency() const;	//m_sCouponFrequency
	const char * GetCompoundFrequency() const; //m_sCompoundFrequency
	const char * GetInterestBasis() const;//m_sInterestBasis
	const char * GetOptionType()	const;	//m_sOptionType
	const char * GetMaturityTerm()	const;	//m_sMaturityTerm
	const char*	 GetTermToMaturity()const;//根据相关条件特别处理了	 //修正的m_sTermToMaturity
	const char*	 GetTermToMaturity2D() const;//m_sTermToMaturity

	const char * GetFRNIndexID()	const;		//m_sFRNIndexID
	const char * GetFixingMADays()	const;		//m_sFixingMADays
	const char * GetCouponRateCurrent()	const;	//m_sCouponRateCurrent
	const char * GetWarranter() const;			//m_sWarranter
	const char * GetBondTag() const;			//m_sBondTag

	double		 GetPlannedIssueAmount() const;	//m_fPlannedIssueAmount
	double		 GetActualIssueAmount()	const;	//m_fActualIssueAmount
	double		 GetOutstandingAmount() const;	//m_fOutstandingAmount
	const char * GetIssuerCode() const;			//m_sIssuerCode
	const char * GetInstitutionType() const;	//m_sInstitutionType



	const char * GetYieldCurveType()	const;	//m_sYieldCurveType

	//const char * GetCSYield()			const;				//m_sCSYield	
	//const char * GetCSCleanPrice()		const;			//m_sCSCleanPrice
	//const char * GetCSModifyDuration()	const;		//m_sCSModifyDuration
	//UINT		 GetCSDate()			const;				//m_nCSDate

	const char * GetAutcionType()		const;		//m_sAutcionType
	const char * GetAuctionDateStart()	const;
	const char * GetAuctionDateEnd()	const;
	const char * GetAuctionDateTime()	const;
	const char * GetAnnounceDate()		const;
	int			 GetIssueType();
	// PRIM - 3130  利差的判断条件：Auction表Auction_Type=SPD 或 bond表Coupon_Type=FRN  申购页面
	int			 GetIssueTypePurchase();
	const char * GetIssueStartDate()	const;
	const char * GetIssueEndDate()		const;
	const char * GetIssueEndTime()		const;
	const char * GetIssuePeriod()		const;
	int			 GetAuctionTimeStart()	const;
	int			 GetAuctionTimeEnd()	const;

	int			 GetIsQuotTopflag()		const;
	char		 GetMortgage()			const;
	char		 GetCrossmarket()		const;
	char		 GetIsMunicipal()		const;

	const char * GetWarrant()			const;
	const char * GetMainUnderwriters()	const;	//m_sMainUnderwriters
	const char * GetJointUnderwriters()const;	//m_sJointUnderwriters
	const char * GetUnderwrites()		const;		//m_sUnderwrites
	const char * GetBidLimitBottom()	const;	//m_sBidLimitBottom
	const char * GetBidLimitTop()		const;		//m_sBidLimitTop

	const char * GetAuctionFlr()		const;		//m_sAuction_Flr
	const char * GetAuctionCap()		const;		//m_sAuction_Cap
	const char * GetAuctionStep()		const;		//m_sAuction_Step
	const char * GetAuctionUnit()		const;		//m_sAuction_Unit

	const char * GetRemainDate()		const;
	const char * GetSceniority()		const;
	const char * GetCategoryFlag()		const;

	std::string  GetBondName()			const;		//m_sFullName
	const char * GetBondShortName()	const;		//中文：m_sShortName;  英文:m_sFullNameEn
	std::string GetBondNameEn()		const;	//m_sFullNameEn
	std::string GetBondShortNameEn()	const;	//m_sShortNameEn

	const char * GetOutlook()			const;		//m_sOutlook
	const char * GetEntCor()			const;

	int			 GetBondFileNum()		const;		//m_nBondFileNum
	int			 GetOptionInfoIndex()	const;		//m_nOptionInfoIndex

	const char *    GetIssueRate()				const;
	const char *	GetPlannedExerciseDate()	const;
	const char *    GetNextCoupon_Date()		const;
	const char *    GetConversionRate()			const;
	const char*		GetAssetStatus()			const;		//m_sAssetStatus
	const char* GetPrincipalPayType() const;
	bool IsAmortizing() const;//提前还本
	bool IsNonAmortizing() const;//到期一次还本

	int			GetCdcAuth()		const;		//m_nCdcAuth
	int			GetOutlookLevel()	const;		
	bool		IsExpireInHoliday() const;		//m_bExpireInHoliday


	const char*		GetCBRRating()const;
	const char*		GetChinaDCState()const;

	const char*		GetCDCRating()const;
	const char*		GetCSIRating()const;

	const char*		GetCurrency()const;			//m_sCurrency
	//////////////////////////////////////////////////////////////////////
	// 
	//其它函数
public:
	const CAdditionBondInfo* GetAdditionInfo()const;					//m_nAdditionInfoIndex
	bool	IsAddIssueBond()const;									//判断是否增续发
	bool	IsFilterOutAddIssueBond()const;							//true表示需要过滤掉增续发券

	//const CBondOptionInfo*	GetOptionInfo();		//m_nOptionInfoIndex

	long	GetRemainedDays(time_t tNow) const;		//返回剩余期限加号前的时间
	const char * GetRemainPeriod(time_t tNow);	//获取剩余期限
	const char* GetRemainPeriodByIntTime(int tNow);	//获取剩余期限
	std::string GetHistoryRemainPeriod(time_t tday) const;	//获取任意时刻的剩余期限
	void	CalcRemainPeriod(time_t tNow);			//
	void	CalcRemainPeriodNew(time_t tNow, char* sRemain, int strLen, bool checkOutstandingAmount /*= true*/, bool useIntTime = false);
	float	GetRemainYear(time_t tNow) const;			//获取剩余期限，返回浮点，单位年
	float	GetRemainYearToOption(time_t tNow) const;	//获取到行权日的剩余期限，返回浮点，单位年

	int		GetMemoryBytes(int& validbytes)const;
	int		GetFieldByOffset(int offset, void* buf, int capcity, int& type)const;
	static void RecordRepeatCheck();
	static void ChangeFieldMode(bool getName);
	//static void CheckEqual(CBondInfoImpl* impl, CBondInfoOld* old);
public:
	void SetValidity(bool valid);

	// Attributes
	bool	IsValidBond()const;		// 债券信息是否正确
	bool	IsExpireBond()const;		// 已过期债券
	bool	IsRight()const;			// 是否权证
	bool	IsNewBond()const;			// 是否新发债
	bool	IsWarranted()const;		// 债券是否担保
	bool	IsRebated()const;			// 债券是否一级半，新发债
	bool	IsMortgage()const;			// 债券是否可质押
	bool	IsCrossMarket()const;		// 债券是否跨市场
	bool	IsSOEenterType()const;		// 债券是否国企债
	bool	IsRatingDebt()const;		// 是否利率债
	bool	IsMunicipal()const;		// 是否城投债
	bool	IsInterbank()const;			// 是否银行间
	bool	IsExchange()const;			// 是否交易所

	bool	IsSSEBond()const;			// 是否上交所
	bool	IsSZEBond()const;			// 是否深交所
	bool	IsBSEBond()const;			// 是否北交所

	bool    IsFinanceBond()const;		//是否金融债
	bool	IsCNYBond()const;			//是否人民币债券

	bool	GetQuotTopflag()const;		// 取置顶报价
	int		DigitBit()const;			// 得到价格有几位小数位

	bool	MatchJianpin(const char* pstr)const;	//简拼匹配
	bool	MatchQuanpin(const char* pstr)const;	//全拼匹配


	//@add by tony 20160218
	bool	CheckCommonUseType(const BLHCONDITION& Cond )const;	//判断常用：电力、钢铁等项
	bool	CheckCommonUseType(UINT nSubType)const;
	bool	IsCommonUseType(const char* sType, int swLevel = 2)const;


	bool	CheckBondTypeNew(const BLHCONDITION& Cond)const;		//判断产品类型，5.5.3新版筛选，最优报价
	bool	CheckBondTypeNew(UINT nSubType)const;

	bool	CheckCmbcBondType(BLHCONDITION & Cond)const;		//判断产品类型：金融债、短融、中票或私募 ABS
	bool	CheckCmbcBondType(UINT nSubType)const;

	bool	CheckBjrcbBondType(BLHCONDITION & Cond)const;		//判断产品类型：国债、金融债、短融、中票、ABS、PPN
	bool	CheckBjrcbBondType(UINT nSubType)const;

	bool	CheckNbcbCDBondType(BLHCONDITION & Cond)const;
	bool	CheckNbcbCDBondType(UINT nSubType)const;

	bool	CheckNbcbIRDBondType(BLHCONDITION & Cond)const;
	bool	CheckNbcbIRDBondType(UINT nSubType)const;

	bool	CheckNbcbIssueBondType(BLHCONDITION & Cond)const;
	bool	CheckNbcbIssueBondType(UINT nSubType)const;

	bool	ShortCheckBondType(const BLHCONDITION & Cond)const;//短融、超短融类型判断,add bushion 20150810
	bool	ShortCheckBondType(UINT nSubType)const;//短融、超短融类型判断,add bushion 20150810

	bool	CheckHYBondType(const BLHCONDITION & Cond)const;		//宏源旗舰店产品类型判断 add bushion 2016229
	bool    CheckHYBondType(const UINT nSubType)const;

	bool	CheckComplexBondType(const BLHCONDITION & Cond)const;
	bool    CheckComplexBondType(UINT nSubType)const;

	bool	CheckBontSubType(const BLHCONDITION & Cond )const;	//判断产品类型细分：细分 例如国债：记账式国债、储蓄国债、凭证式国债
	bool	CheckBontSubType(const char* pSubType)const;

	bool	CheckRightEx(const BLHCONDITION& Cond) const;		//含权类型
	bool	CheckIssuer(const BLHCONDITION& Cond)const;			//判断发行人
	bool	CheckGuarantor(const BLHCONDITION& Cond)const;		//担保人
	bool	CheckSector(const BLHCONDITION& Cond)const;		//判断行业
	bool	CheckSector2021(const BLHCONDITION& Cond)const;		//判断2021申万行业
	bool	CheckSector2021(const std::vector<std::string>& vctSector2021)const;//判断2021申万行业
	bool	CheckArea(const BLHCONDITION & Cond)const;			//判断地区
	bool	CheckMuniArea(const BLHCONDITION& Cond)const;			//判断城投地区
	bool	CheckLocalBondArea(const BLHCONDITION& Cond)const;		//判断地方债地区
	bool	CheckMainUnderwriter(const BLHCONDITION& condStr) const;	//判断主承机构

	bool	CheckDebtRating(const BLHCONDITION & Cond )const;	//判断债项  m_sBondRating
	bool	CheckFinDebt(const BLHCONDITION & Cond )const;		//判断金融债：国开，非国开
	//  add  by  lbl    NCD 评级
	bool	CheckNCDRating(const BLHCONDITION& Cond)const;		//判断NCD 评级
	//end 
	bool	CheckIssueYear(const BLHCONDITION & Cond )const;		//判断发行年份
	bool	CheckIssueYear(int nYear) const;
	bool	CheckIssueYear(int nBegin, int nEnd)const;
	bool	CheckUnderwriter(const BLHCONDITION & Cond )const;	//判断在团	
	bool	IsTransBond()const;									//可转债 CVB或者SCV
	bool    IsCVBBond()const; //不可分离债，深交所的可转债判定标准

	bool	IsBondCommercialBank() const;	//商业银行债
	bool	IsBondSceniority()const;	//次级新
	bool	IsBondTLAC()const;	//TLC

	bool	IsBondSWFirstBank()const;		//申万一级为银行
	bool	IsBondSubordinate() const;
	bool	IsBondBankSecond() const;		//银行二级债
	bool	IsBondBankPerpetual() const;	//银行永续债
	bool	IsPolicyBankSecond() const;		//政策性次级

	bool	IsBondFinancialInstitutions()const;	// 金融机构债
	bool	IsCreditBond(const BLHCONDITION & Cond )const;		//信用债,利率债

	bool	is_interest_bond() const;
	bool	is_credit_bond() const;
	bool    is_industry_bond()const; //是否产业债

	bool	IsSuperNewBond(const BLHCONDITION & Cond)const;		//超级新债通
	bool	IsInDays(const BLHCONDITION & Cond )const;			//年份：在发行、公告、缴款或者上市日期间 超级新债通过滤时间
	bool	CheckIssueState(BLHCONDITION & Cond) const;	//发行状态判断:不限、发行中、已发行、预发行

	bool	CheckAssetStatus(const BLHCONDITION & Cond) const;	//发行，公募，私募，小私募
	bool	CheckAssetStatus(UINT nStatus) const;
	bool	CheckABSCoupon(const BLHCONDITION & Cond) const;	//ABS票面
	bool	CheckABSCoupon(int nCouponType) const;
	bool	CheckCouponRate(const BLHCONDITION& Cond) const;	//票面利率
	bool	CheckCategoryFlag(const BLHCONDITION& Cond) const;	//专项债具体类型
	bool	CheckBankBondType(const BLHCONDITION& Cond) const;

	const char * GetArea(bool eng = false)const;			//地区名称
	const char * GetSwSector(bool eng = false)const;		//一级行业名称
	const char * GetSwSubSector(bool eng = false)const;		//二级行业名称
	const char * GetInstitutionShortName(bool eng = false)const;//机构简称
	const char * GetInstitutionFullName(bool eng = false) const;//发行人机构全称
	const char * GetRatingInstitutionShortName(bool eng = false)const;//评级机构简称

	const char * GetCouponTypeName(bool eng = false)const;		//票面利率方式名称
	const char * GetOptionTypeName(bool eng = false)const;		//行权方式名称
	const char * GetOutlookName(bool eng = false)const;			//展望名称
	const char * GetIssuerBondRating() const;	//主体与债项评级组合字段
	const char * GetIssuerRatingEx() const;	//m_sInstitutionRating为AAA+时，返回aaa+，否则返回m_sIssuerRating

	bool CheckBondSubType(const std::string& sType)const;//2016/08/29,bushion.xin:判断m_SubType

	//产品债券类型判断函数，非通用的需要自己重写判断函数
	bool IsBondCountry() const;		//国债   1
	bool IsBondCenter() const;		//央票	 2
	bool IsBondFinance() const;		//金融债 3
	bool IsBondLocal() const;		//地方债 4
	bool IsBondShort() const;       //短融中包括超短融 5
	bool IsBondShort_S() const;     //短融中去掉超短融 5
	bool IsBondCShort() const;      //超短融 6
	bool IsBondMTN() const;			//中票   7
	bool IsBondChina() const;		//中票   7

	bool IsBondEnterpr() const;		//企业债 8
	bool IsBondCorporate() const;	//公司债 9 （不含非公开公司债）
	bool IsBondNonPublicCor() const;//非公开公司债 10
	bool IsBondCOP() const;			//公司债（所有公司债，含9，10）

	bool IsBondCorporateV2() const;	//公司债（不含可转债）
	bool IsBondCOPV2() const;		//公司债（不含可转债）

	bool IsBondPPN() const;			//PPN  11
	bool IsBondNCD() const;			//NCD  12
	bool IsBondABS() const;			//ABS  13
	bool IsBondCRM() const;			//CRM  14
	bool IsBondPrivate() const;		//私募债 包括10和11


	bool IsBondSecondCapital() const;//二级资本债 15
	bool IsBondPDB() const;			 //熊猫债     16
	bool IsBondGKZ() const;			 //国开债     17
	bool IsBondInAndEx() const; //进出口
	bool IsBondAgDev() const; //农发债

	bool IsBondOther() const;		 //其它债     18  暂停使用，各页面自己负责其它债逻辑处理


	bool IsPrivateDebet() const;	//私募债，包括PPN和ABS 


	bool IsPrivateCorpBond() const; //私募公司债
	bool IsPubliceCorpBond() const;  //公募公司债
	bool IsETSBond() const; //true表示永续债
	bool IsListedCompany()const;				//true表示上市公司债券
	bool IsCBRC_Financing_Platform()const;	//true表示平台债				

	bool IsCDCAuthValid() const; //是否有中债估值权限

	bool IsGreenBond(void) const; //是否绿色债
	bool IsCarbonNeutrality(void) const; //是否碳中和

	bool IsBondRailway(void) const;//是否铁道债
	bool IsBondInsurance(void) const; //是否保险债
	bool IsBondBroker(void) const; //是否券商债
	bool IsBondBroker_Corp(void) const;//是否证券公司
	bool IsBondBroker_Short(void) const; //是否证券公司短融
	bool IsBondBroker_Second(void) const; //是否证券次级
	bool IsBondBank(void) const;//是否商金债
	bool IsBondFinancialOther(void) const;//是否其他金融机构债

protected:
	// 字符串优化
	/*
		[内存优化][scofined.qi]
		1.全部债权数据的快速拼音过滤,已经有拼音搜索系统来支撑,
		  无需暂存每个债券的简拼/全拼来做过滤,
		2.即时生成简拼/全拼的算法已经做过优化,性能已经足够快
		因此,暂存简拼全拼,除了耗费多余的内存,没有必要
		此次优化,将简拼全拼暂存字段移除
	*/
	//ClassMember<std::string, PackedString<200, 47>, kOptimizeTypePackedString> m_sJianpin;		//简拼					编码：------
	//ClassMember<std::string, PackedString<200, 111>, kOptimizeTypePackedString> m_sQuanpin;	//全拼					编码：------
	ClassMember<char[16], PackedString<0, 4>, kOptimizeTypePackedString> m_ConversionRate;	// 质押比
	ClassMember<char[16], PackedString<0, 4>, kOptimizeTypePackedString> m_sBidLimitBottom;	//投标区间下限
	ClassMember<char[16], PackedString<0, 4>, kOptimizeTypePackedString> m_sBidLimitTop;	//投标区间上限
	ClassMember<char[16], PackedString<0, 9>, kOptimizeTypePackedString> m_IssueRate;		//发行利率
	ClassMember<char[12], PackedString<0, 7>, kOptimizeTypePackedString> m_sCouponRateCurrent;	//中标价格,票面利率
	ClassMember<char[64], PackedString<0, 9>, kOptimizeTypePackedString> m_sWarranter;			//担保人
	ClassMember<char[32], PackedString<0, 4>, kOptimizeTypePackedString> m_sBondTag;			//标签，绿色债，碳中和等
	/*
		[内存优化][scofined.qi]
		鉴于这三个字段使用频率过低,且占用内存较大,
		使用MappedOffsetString将内容刷新到映射文件中,
		只在内存中保留映射文件对应的偏移量,
		即MappedOffsetString的成员m_id
		需要读取的时候,使用特殊方式从映射文件中,
		移动映射视口来读取指定偏移量的字符串

		由于映射文件的特殊访问方式,访问该字段时不能通过指针
		必须要通过std::string以值拷贝的方式来获取
		因此,相应的接口返回值都有const char* 改成std::string
	*/
	ClassMember<std::string, PackedString<00, 92>, kOptimizeTypePackedString> m_sFullName;	//债券全称
	ClassMember<std::string, PackedString<200, 127>, kOptimizeTypePackedString> m_sFullNameEn;//债券英文全称
	ClassMember<std::string, PackedString<200, 52>, kOptimizeTypePackedString> m_sShortNameEn;	//债券英文简称

	ClassMember<std::string, PackedString<0, 39>, kOptimizeTypePackedString> m_sShortName;		//债券简称
	ClassMember<char[42], PackedString<0, 27>, kOptimizeTypePackedString> m_sCombBondKey;	//带有市场后缀的BondKey   "A0000012012CORLEB01.CIB"
	ClassMember<char[33], PackedString<0, 23>, kOptimizeTypePackedString> m_sBondKey;		//债券编码  "A0000012012CORLEB01"
	ClassMember<char[20], PackedString<0, 19>, kOptimizeTypePackedString> m_sCombBondID;	//带有市场后缀的BondCode  "1280309.IB"	
	ClassMember<char[32], PackedString<0, 11>, kOptimizeTypePackedString> m_sRemainDate;		//剩余期限，不含永续债+N
	ClassMember<char[32], PackedString<0, 11>, kOptimizeTypePackedString> m_sRemainDateDisplay;	//界面显示的剩余期限
	ClassMember<char[32], PackedString<0, 32>, kOptimizeTypeNone>		 m_CategoryFlag;//专项债字段
	ClassMember<char[16], PackedString<0, 4>, kOptimizeTypePackedString> m_sTermToMaturity;		//偿还期限， "X+Y"
	ClassMember<char[12], PackedString<0, 4>, kOptimizeTypePackedString> m_sIssueEndTime;		//发行截止时间	"1630"	add by lance 2015.6.25
	ClassMember<char[12], PackedString<0, 4>, kOptimizeTypePackedString> m_sAuctionDateTime;	//招标建档时间

	/*
		[内存优化][scofined.qi]
		原先日期使用32位的4字节来表示年月日,年用ushort表示
		现在,日期改用DateStringMap中的ShortDate来表示
		年用7bit表示,以1980(即DateStringMap::YEAR_BASE)开始
		最大支持到DateStringMap::YEAR_MAX,跨度127年
		月用4个bit表示,合法月份只有1-12
		日用5bit表示,合法日期只有1-31
		使用新编码改进后,日期字段成员所占内存消减一半
	*/
	ClassMember<char[9], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_NextCoupon_Date;			// 下一付息日
	ClassMember<char[9], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_PlannedExerciseDate;		// 下一行权日
	ClassMember<char[12], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_sAuctionDateEnd;		//招标建档截止日
	ClassMember<char[12], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_sOptionDate;			//行权日期				编码："19860414"
	ClassMember<char[12], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_sAuctionDateStart;	//招标建档起始日
	ClassMember<char[12], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_sIssueEndDate;		//发行截止日
	ClassMember<char[12], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_sPaymentDate;			//缴款日				编码："19860414"
	ClassMember<char[12], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_sAnnounceDate;		//公告日期
	ClassMember<char[12], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_sIssueStartDate;		//发行起始日 "20121010"
	ClassMember<char[12], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_sInterestStartDate;	//起息日				编码："20121010"
	ClassMember<char[12], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_sListDate;			//上市日期			    编码："20121019" YYYYMMDD(年月日)
	ClassMember<char[12], DateStringMap<100, 8000>, kOptimizeTypeDate>	m_sMaturityDate;		//到期日				编码："20181010"

	// 小字符串优化
	ClassMember<std::string, TinyStringMap<1, 79>, kOptimizeTypeTinyMap> m_sYieldCurveType;		//曲线类型			"CDC.CHI.MUB.AA-"
	ClassMember<std::string, TinyStringMap<2, 511>, kOptimizeTypeTinyMap> m_sJointUnderwriters;	//联席承销商
	ClassMember<std::string, TinyStringMap<3, 3>, kOptimizeTypeTinyMap> m_sUnderwrites;			//承销商列表，逗号分隔
	ClassMember<char[9], TinyStringMap<4, 15>, kOptimizeTypeTinyMap>  m_sIssuerRatingInstitutionCode;	//发行人评级机构代码
	ClassMember<char[9], TinyStringMap<5, 3>, kOptimizeTypeTinyMap>  m_sAuction_Unit;		//标位单位
	ClassMember<char[9], TinyStringMap<6, 5>, kOptimizeTypeTinyMap>  m_sIssueType;			//招标方式
	ClassMember<char[8], TinyStringMap<7, 6>, kOptimizeTypeTinyMap>  m_sOutlook;			//展望

	/*
		[内存优化][scofined.qi]
		KeyString针对长度<=3的字符串做了特殊优化
		只需要4个字节,就可以表示长度<=3的字符串
		针对长度>=4,且<=255的字符串,总共需要4+1+字符串+1末尾的内存
		针对长度>=256的字符串,总共需要4+2+字符串+1末尾的内存
		其中,4是指针,1/2是表示长度所需要的内存,获取长度是O(1)时间复杂度
	*/
	//ClassMember<char[8], TinyStringMap<8, 3>, kOptimizeTypeNone>  
	qb::base::KeyString												 m_sListedMarket;		//CIB/SSE/SZE 代表不同的市场 "CIB"
	ClassMember<char[8], TinyStringMap<9, 10>, kOptimizeTypeTinyMap>  m_sOptionType;		//选择权类型			含权："NON" 显示'否';否则显示'是'是否含权
	ClassMember<char[8], TinyStringMap<10, 4>, kOptimizeTypeTinyMap>  m_sAutcionType;		//发行方式
	ClassMember<char[8], TinyStringMap<11, 7>, kOptimizeTypeTinyMap>  m_sEntCor;			//公司标识字段   
	ClassMember<char[8], TinyStringMap<12, 5>, kOptimizeTypeTinyMap>  m_sInstitutionType;	//机构类型			"LGE"
	ClassMember<char[4], TinyStringMap<13, 4>, kOptimizeTypeTinyMap>  m_sMarketType;		//市场类型				1级，2级
	ClassMember<char[4], TinyStringMap<14, 44>, kOptimizeTypeNone>  m_sBondSubType;			//债劵子类别:国债，央票等  参考BONDTYPE2LOG(UINT nType)函数 BGB,SGB等字符
	ClassMember<char[4], TinyStringMap<15, 6>, kOptimizeTypeTinyMap>  m_sInterestBasis;		//利息基础
	ClassMember<char[4], TinyStringMap<16, 6>, kOptimizeTypeTinyMap>  m_sCouponFrequency;	//付息频率
	ClassMember<char[4], TinyStringMap<17, 6>, kOptimizeTypeTinyMap>  m_sCompoundFrequency;	//计息频率
	ClassMember<char[33], TinyStringMap<18, 9>, kOptimizeTypeTinyMap>  m_sWarrant;				//担保
	ClassMember<char[32], TinyStringMap<19, 1023>, kOptimizeTypeTinyMap>  m_sMainUnderwriters;	//主承销商 "X000068"
	ClassMember<char[17], TinyStringMap<20, 4>, kOptimizeTypeTinyMap>  m_sIssuePeriod;			//募集时间 "9月上旬"等 add by lance 2015.9.9
	ClassMember<char[17], TinyStringMap<21, 13>, kOptimizeTypeTinyMap>  m_sAuction_Step;	//步长
	ClassMember<char[16], TinyStringMap<22, 22>, kOptimizeTypeTinyMap>  m_sFRNIndexID;		//基础利率代码
	ClassMember<char[12], TinyStringMap<23, 23>, kOptimizeTypeTinyMap>  m_sIssuerRating;	//发行人最新评级,主体评级： AAA AA+等
	ClassMember<char[12], TinyStringMap<24, 22>, kOptimizeTypeTinyMap>  m_sBondRating;		//最新债项评级： AAA AA+等
	ClassMember<char[12], TinyStringMap<25, 3>, kOptimizeTypeTinyMap>  m_sInstitutionRating;	//取institution_info表的institution_rating字段，主体评级，含AAA+
	ClassMember<char[12], TinyStringMap<26, 6>, kOptimizeTypeTinyMap>  m_sRateType;		//利率类型 票面			编码："Shibor","Depo","固息","FIXED" 
	ClassMember<char[12], TinyStringMap<27, 5>, kOptimizeTypeTinyMap>  m_sCouponType;	//利率方式				add by lance 2015.6.25
	ClassMember<char[10], TinyStringMap<28, 8>, kOptimizeTypeTinyMap>  m_sMaturityTerm;	//偿还期限	 "6Y"
	ClassMember<char[12], TinyStringMap<12, 4>, kOptimizeTypeTinyMap>  m_sCBRRating;	//中债资信评级
	ClassMember<char[12], TinyStringMap<12, 6>, kOptimizeTypeTinyMap>  m_sChinaDCState;	//中债资信状态
	ClassMember<char[12], TinyStringMap<12, 6>, kOptimizeTypeTinyMap>  m_sCDCRating;	//中债隐含评级
	ClassMember<char[12], TinyStringMap<12, 6>, kOptimizeTypeTinyMap>  m_sCSIRating;	//中证隐含评级
	ClassMember<char[8], TinyStringMap<8,4>, kOptimizeTypeTinyMap>  m_sCurrency;	//货币种类

protected:// 不优化的字符串字段
	ClassMember<char[13], PackedString<0, 13>, kOptimizeTypeNone> m_sBondID;			//债券代码	"1280309"
	//ClassMember<char[12], PackedString<0, 12>, kOptimizeTypeNone> m_sCSCleanPrice;		//中证估值净价
	//ClassMember<char[12], PackedString<0, 12>, kOptimizeTypeNone> m_sCSYield;			//中证估值收益率
	//ClassMember<char[12], PackedString<0, 12>, kOptimizeTypeNone> m_sEstcleanprice;		//估值净价
	//ClassMember<char[12], PackedString<0, 12>, kOptimizeTypeNone> m_sEstPrice;			//估值收益率		中债估值
	//ClassMember<char[12], PackedString<0, 12>, kOptimizeTypeNone> m_sFrontEstcleanprice;	//上一次 估值净价
	//ClassMember<char[12], PackedString<0, 12>, kOptimizeTypeNone> m_sFrontEstPrice;			//上一次 估值收益率		中债估值

	ClassMember<char[17], PackedString<0, 17>, kOptimizeTypePackedString> m_sAuction_Cap;		////标位上限
	ClassMember<char[17], PackedString<0, 17>, kOptimizeTypePackedString> m_sAuction_Flr;		//标位下限
	ClassMember<char[4], PackedString<0, 4>, kOptimizeTypeNone> m_sFixingMADays;		//基准利率计算周期（平均）
	//ClassMember<char[8], PackedString<0, 8>, kOptimizeTypeNone> m_sCSModifyDuration;	//中证估值久期
	ClassMember<char[8], PackedString<0, 8>, kOptimizeTypeNone> m_sIssuerCode;			//发行人代码		"A000001" 判断金融债
	ClassMember<char[4], PackedString<0, 4>, kOptimizeTypeNone>  m_Sceniority;	//次级债字段


	/*
		[内存优化][scofined.qi]
		KeyString针对长度<=3的字符串做了特殊优化
		只需要4个字节,就可以表示长度<=3的字符串
		针对长度>=4,且<=255的字符串,总共需要4+1+字符串+1末尾的内存
		针对长度>=256的字符串,总共需要4+2+字符串+1末尾的内存
		其中,4是指针,1/2是表示长度所需要的内存,获取长度是O(1)时间复杂度
		统计数据表明,m_sAssetStatus字段的平均长度只有0.24,最大长度只有3
		非常适合专门针对较短字符串做过特殊存储优化的KeyString
	*/
	//ClassMember<char[8], PackedString<0, 8>, kOptimizeTypeNone> m_sAssetStatus;			//资产类型 PRI-私募，PUB-小公募，NULL-公募
	qb::base::KeyString m_sAssetStatus;//
	qb::base::KeyString m_sPrincipayPayType;
protected:// 不优化的字段
	double			m_fPlannedIssueAmount;				//预期发行量		100000
	double			m_fActualIssueAmount;				//实际发行量		add by lance 2015.6.25
	double			m_fOutstandingAmount;				//债券余额（以万为单位）add by lance 2016.6.20
	int				m_nBondFileNum;						//可下载文件数量
	int				m_nAdditionInfoIndex;				//增续发信息在vector中的index;
	int				m_nOptionInfoIndex;					//行权数据在vector中的index
	//UINT			m_nEstDate;							//估值日期
	//UINT			m_nCSDate;							//中证估值日期
	int				m_nAuctionTimeStart;				//发行开始时间
	int				m_nAuctionTimeEnd;					//发行结束时间
	int				m_nCdcAuth;							//中债估值对应权限
	int				m_nOutlookLevel;					//展望，用户排序
	int				m_nPayDate;				//实际兑付日			编码："20181010"
protected:// 优化比特位字段
	FieldFlag		m_flag;
protected://原先注释的字段
	//int			m_nIsWarrant;						//担保
	//char			m_sIsUnderwriter;					//是否在团 '0'

};
